var common = require('../demo/common/common.js')
const app = getApp();
Page({
  data: {
  },
  goMobile: function (e) {
    var id = e.currentTarget.dataset.id;
    var name = e.currentTarget.dataset.name;
    console.log(id);
    wx.setStorageSync('orgId', id),
      wx.setStorageSync('orgName', name),
      wx.navigateTo({
        url: '../mobile/mobile',
        success: function (res) { },
        fail: function (res) { },
        complete: function (res) { },
      })
  },
  onLoad: function (options) {
    var that = this;
    var openId = wx.getStorageSync('openId');
    common.check(openId, function () {
      that.requestData(openId);
    })

  },
  //请求后台数据
  requestData: function (openId) {
    console.log('requestData');
    var that = this;

    wx.showLoading({
      title: '数据加载中'
    });
    wx.request({
      url: app.globalData.mpurl + 'group/getFollowList',
      method: "GET",
      data: {
        openId: openId
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      success: function (res) {
        res = res.data;
        console.log(res);
        if (res.code == '00') {
          that.setData({ respData: res.data });
        } else if (res.code == '01') {
          that.setData({ respData: res.data });
          wx.showModal({
            title: '提示',
            content: "你没有关注任何组织",
            showCancel: false,
          })
        } else {
          wx.showModal({
            title: '提示',
            content: '获取信息失败',
            showCancel: false,
          })
        }
      },
      fail: function (res) {
        wx.showModal({
          title: '提示',
          content: "系统异常，请稍候再试",
          showCancel: false
        })
      },
      complete: function () {
        wx.hideLoading();
      }
    });

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    console.log("onPullDownRefresh");
    wx.showNavigationBarLoading();
    this.onLoad();
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '手机群录',
      path: 'pages/sign/sign'
    }
  }
})

